package com.subaiqiao.yunshiyuan.entrance.ysy.mapper;

import com.subaiqiao.yunshiyuan.basis.mapper.BasisMapper;
import com.subaiqiao.yunshiyuan.entrance.ysy.pojo.Article;
import com.subaiqiao.yunshiyuan.entrance.ysy.vo.ArticleVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author 曹朝禹
 * @since 2022-05-13
 */
@Mapper
public interface ArticleMapper extends BasisMapper<Article> {

    @Select("SELECT article.*,a.nickname,b.sys_category_name FROM `article` LEFT JOIN user_info a ON article.article_author=a.user_id LEFT JOIN sys_category b ON article.article_category=b.sys_category_id WHERE article.article_id=#{articleId}")
    ArticleVO FindById(Integer articleId);

    @Select("SELECT COUNT(*) FROM article")
    Integer FindArticleCount();

    @Select("SELECT COUNT(*) FROM article WHERE status=1")
    Integer FindArticleDisableCount();

    @Select("SELECT COUNT(*) FROM article WHERE TO_DAYS(NOW()) - TO_DAYS(create_datetime)=1")
    Integer FindArticleCountYesterdayRegister();
}
